import {
	http,
	Method
} from "@/utils/request.js";

/**
 * 拼团列表
 */
export function getPinTuanList(params) {
	return http.request({
		url: `/promotion/pintuan`,
		method: Method.GET,
		params,
	});
}

// 查询拼团详情
export function getPinTuanDetail(params) {
	return http.request({
		url: `/promotion/pintuan/${params.id}`,
		method: Method.GET,
		params,
	});
}

// 新建 拼团
export function savePinTuan(params) {
	return http.request({
		url: `/promotion/pintuan`,
		method: Method.POST,
		header: {
			'content-type': 'application/json'
		},
		data: params,
	});
}

// 编辑拼团
export function editPinTuan(params) {
	return http.request({
		url: `/promotion/pintuan`,
		method: Method.PUT,
		header: {
			'content-type': 'application/json'
		},
		data: params,
	});
}



// 限时秒杀活动列表
export function getSeckillList(params) {
	return http.request({
		url: `/promotion/seckill`,
		method: Method.GET,
		params,
	});
}

// 限时秒杀活动详情
export function getSeckillDetail(seckillId) {
	return http.request({
		url: `/promotion/seckill/${seckillId}`,
		method: Method.GET,
	});
}

// 限时秒杀活动商品
export function getSeckillGoodsList(params) {
	return http.request({
		url: `/promotion/seckill/apply`,
		method: Method.GET,
		params
	});
}


// 添加限时抢购 商品
export function addSeckillGoodsList(params) {
	return http.request({
		url: `/promotion/seckill/apply/${params.seckillId}`,
		method: Method.POST,
		header: {
			'content-type': 'application/json'
		},
		data: params.data,
	});
}

// 满减满赠活动列表
export function getFullDiscountList(params) {
	return http.request({
		url: `/promotion/fullDiscount`,
		method: Method.GET,
		params
	});
}


// 通过id获取满减活动
export function getFullDiscountDetail(id) {
	return http.request({
		url: `/promotion/fullDiscount/${id}`,
		method: Method.GET,
	});
}

// 获取优惠券列表
export function getShopCouponList(params) {
	return http.request({
		url: `/promotion/coupon`,
		method: Method.GET,
		params
	});
}

// 请求加价购活动列表
export function addGoodsListAsync() {
	return http.request({
		url: `/promotion/huangou/byPage`,
		method: Method.GET,
	});
}

// 请求加价购活动列表
export function addGoodsByIdAsync(id) {
	return http.request({
		url: `/promotion/huangou/${id}`,
		method: Method.GET,
	});
}

// 修改/新增加价购活动列表
export function setAddGoodsByIdAsync(data) {
	return http.request({
		url: `/promotion/huangou`,
		method: data.id ? Method.PUT : Method.POST,
		data
	});
}